package cn.ycc1.springioc;

/**
 * 打印当前线程的堆栈信息
 * @author ycc
 * @date 2024/11/10
 */
public class StackTraceExample {
    public static void printStackTrace() {
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
        for (StackTraceElement element : stackTrace) {
            System.out.println(element.toString());
        }
    }

    public static void main(String[] args) {
        methodA();
    }

    public static void methodA() {
        methodB();
    }

    public static void methodB() {
        printStackTrace();
    }
}
